#define _CRT_SECURE_NO_WARNINGS 1

#include "SList.h"

void SLTPrint(SLTNode* phead)
{
	SLTNode* cur = phead;
	while (cur != NULL)
	{
		printf("%d->", cur->data);
		cur = cur->next;
	}
	printf("NULL\n");
}

SLTNode* SLTMallocNode(SLTDataType x)
{
	SLTNode* ptr = (SLTNode*)malloc(sizeof(SLTNode));
	if (ptr == NULL)
	{
		perror("malloc fail");
		return NULL;
	}
	ptr->data = x;
	ptr->next = NULL;
	return ptr;
}

void SLTPushBack(SLTNode** phead, SLTDataType x)
{
	if (*phead == NULL)
	{
		*phead = SLTMallocNode(x);
		return;
	}
	SLTNode* cur = *phead;
	while (cur->next != NULL)
	{
		cur = cur->next;
	}
	cur->next = SLTMallocNode(x);

}

void SLTPushFront(SLTNode** phead, SLTDataType x)
{
	SLTNode* cur = SLTMallocNode(x);
	cur->next = *phead;
	*phead = cur;
}

void SLTPopBack(SLTNode** phead);
void SLTPopFront(SLTNode** phead);
